package com.yoga.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yoga.model.Test;
import com.yoga.service.TestService;
import com.yoga.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yan
 * @date 2025/8/20
 */
@RestController
@RequestMapping(value = "/api/v1/test", produces = MediaType.APPLICATION_JSON_VALUE)
public class TestApi {
    private TestService testService;
    @Autowired
    public void setTestService(TestService testService) {
        this.testService = testService;
    }

    @GetMapping
    public ResponseEntity<JsonResult<?>> findAll(Integer pageNo, Integer pageSize, Test test){
        Page<Test> page = new Page<>(pageNo,pageSize);
        page = this.testService.findAll(page,test);
        return ResponseEntity.ok(JsonResult.success(page));
    }
}
